package com.zhongkun.datahome.service.export.handler;

import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import org.apache.poi.ss.usermodel.Sheet;

/**
 * @Author: lifengsheng
 * @Date: 2025/5/13 11:04
 * @Desc
 */
public class DynamicFreezeHandler implements SheetWriteHandler {
    private final int headerRowCount; // 动态传入表头行数

    public DynamicFreezeHandler(int headerRowCount) {
        this.headerRowCount = headerRowCount;
    }


    @Override
    public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
        Sheet sheet = writeSheetHolder.getSheet();
        sheet.createFreezePane(0, headerRowCount);
    }
}
